var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("NotifyEventType"),
    n = e("GlobalParams"),
    i = e("Loader"),
    r = e("AssetsManager"),
    s = e("AudioManager"),
    l = e("EventManager"),
    _ = e("CommonHelper"),
    c = e("sdkConfig"),
    d = e("AD"),
    h = e("Toast"),
    vv = e("AdCenter"),
    u = cc._decorator,
    p = u.ccclass,
    m = u.property,
    f = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.top_view_node = null),
                (t.coinNode = null),
                (t.coinFab = null),
                (t.zs_Node = null),
                (t.zsFab = null),
                (t.sp_node = null),
                (t.spFab = null),
                (t.fhb_node = null),
                (t.fhbFab = null),
                (t.tyk_node = null),
                (t.tykFab = null),
                (t.role_ske_list = [
                    "hero_1/char_jeongsujeong_legend",
                    "hero_2/char_nue",
                    "hero_3/char_singongpyo",
                    "hero_4/ayck",
                    "hero_5/char_hyeongon",
                    "hero_6/char_jangchungun",
                    "hero_7/char_heuggyeon",
                    "hero_8/char_yeumragwi",
                    "hero_9/char_yochun",
                    "hero_10/char_dongcheongun",
                    "hero_11/char_jiho_human",
                    "hero_12/char_yangchun",
                    "hero_13/char_songgang",
                    "hero_14/char_jochungun",
                    "hero_15/char_hikari"
                ]),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.onLoad = function () {
                cc.game.addPersistRootNode(this.node);
                vv.default.getInstance().adFactory.newBanner();
            }),
            (t.prototype.showPopup = function (e, t) {
                var o;
                (c.default.platform == c.EPlatform.OPPO && d.default.getInstance().hideCustomAd(),
                    cc.find("Canvas").getChildByName(e))
                    ? this.showNewPopup(e, t)
                    : ((o = r.default.getInstance().getPrefabNode(e)), this.showNewPopup(e, t, o));
            }),
            (t.prototype.showNewPopup = function (e, t, o) {
                var a = null,
                    n = cc.find("Canvas").children[cc.find("Canvas").childrenCount - 1].zIndex + 1;
                cc.find("Canvas").getChildByName(e)
                    ? (((a = cc.find("Canvas").getChildByName(e)).active = !1), (a.zIndex = n), (a.active = !0))
                    : (((a = cc.instantiate(o)).zIndex = n), cc.find("Canvas").addChild(a)),
                    t && t(a);
            }),
            (t.prototype.showTopView = function (e) {
                this.top_view_node.active = e;
            }),
            (t.prototype.addCoinNum = function (e) {
                var t = function () {
                    var t = n.GlobalParams.PlayerInfo.value;
                    (t.coin += e),
                        (n.GlobalParams.PlayerInfo.value = t),
                        l.EventManager.raiseEvent(a.default.UPDATE_HAVE_COIN_NUMBER);
                };
                if (e < 0) this.playerTaskOverInfo(5, -1 * e), t();
                else {
                    h.default.showNewToast("获得" + e + "个金币", cc.Color.BLACK, -20),
                        s.default.getInstance().playFx("get_coin");
                    var o = this.coinNode.parent.convertToWorldSpaceAR(this.coinNode.getPosition()),
                        i = cc.find("Canvas").convertToNodeSpaceAR(o);
                    this.addAnime(i, this.coinFab, t);
                }
            }),
            (t.prototype.addZsNum = function (e) {
                var t = function () {
                    var t = n.GlobalParams.PlayerInfo.value;
                    (t.zs += e),
                        (n.GlobalParams.PlayerInfo.value = t),
                        l.EventManager.raiseEvent(a.default.UPDATE_HAVE_ZS_NUMBER);
                };
                if (e < 0) this.playerTaskOverInfo(6, -1 * e), t();
                else {
                    h.default.showNewToast("获得" + e + "个钥匙", cc.Color.BLACK, 30),
                        s.default.getInstance().playFx("get_coin");
                    var o = this.zs_Node.parent.convertToWorldSpaceAR(this.zs_Node.getPosition()),
                        i = cc.find("Canvas").convertToNodeSpaceAR(o);
                    this.addAnime(i, this.zsFab, t);
                }
            }),
            (t.prototype.addSpNum = function (e) {
                var t = function () {
                    var t = n.GlobalParams.PlayerInfo.value;
                    (t.debris += e),
                        (n.GlobalParams.PlayerInfo.value = t),
                        l.EventManager.raiseEvent(a.default.UPDATE_HAVE_SP_NUMBER);
                };
                if (e < 0) t();
                else {
                    h.default.showNewToast("获得" + e + "个武魂碎片", cc.Color.BLACK, 30),
                        s.default.getInstance().playFx("get_coin");
                    var o = this.sp_node.parent.convertToWorldSpaceAR(this.sp_node.getPosition()),
                        i = cc.find("Canvas").convertToNodeSpaceAR(o);
                    this.addAnime(i, this.spFab, t);
                }
            }),
            (t.prototype.addFhbNum = function (e) {
                var t = function () {
                    var t = n.GlobalParams.PlayerInfo.value;
                    (t.revive += e),
                        (n.GlobalParams.PlayerInfo.value = t),
                        l.EventManager.raiseEvent(a.default.UPDATE_HAVE_REVIVE_NUMBER);
                };
                if (e < 0) t();
                else {
                    h.default.showNewToast("获得" + e + "个复活币", cc.Color.BLACK, 30),
                        s.default.getInstance().playFx("get_coin");
                    var o = this.fhb_node.parent.convertToWorldSpaceAR(this.fhb_node.getPosition()),
                        i = cc.find("Canvas").convertToNodeSpaceAR(o);
                    this.addAnime(i, this.fhbFab, t);
                }
            }),
            (t.prototype.addTykNum = function (e) {
                var t = function () {
                    var t = n.GlobalParams.PlayerInfo.value;
                    (t.tast_card += e),
                        (n.GlobalParams.PlayerInfo.value = t),
                        l.EventManager.raiseEvent(a.default.UPDATE_HAVE_TASTE_CARD_NUMBER);
                };
                if (e < 0) t();
                else {
                    h.default.showNewToast("获得" + e + "张体验卡", cc.Color.BLACK, 30),
                        s.default.getInstance().playFx("get_coin");
                    var o = this.tyk_node.parent.convertToWorldSpaceAR(this.tyk_node.getPosition()),
                        i = cc.find("Canvas").convertToNodeSpaceAR(o);
                    this.addAnime(i, this.tykFab, t);
                }
            }),
            (t.prototype.addAnime = function (e, t, o) {
                for (
                    var a = function (o) {
                        var a = cc.instantiate(t);
                        (a.active = !0), (a.zIndex = 60);
                        var i = _.default.getRandomInt(-700, 700),
                            r = _.default.getRandomInt(-700, 700);
                        if (!a) return "continue";
                        a.setPosition(cc.v2(i, r));
                        var s = [
                            cc.v2(-50 + _.default.getRandomInt(-50, 50), 100 + _.default.getRandomInt(-50, 50)),
                            cc.v2(
                                -100 + _.default.getRandomInt(-50, 50),
                                300 + _.default.getRandomInt(-50, 50)
                            ),
                            cc.v2(e.x, e.y)
                        ],
                            l = cc.bezierTo(1, s),
                            c = cc.callFunc(function () {
                                a.destroy();
                            });
                        n.scheduleOnce(function () {
                            cc.find("Canvas").addChild(a), a.runAction(cc.sequence(l, c));
                        }, 0.008 * o);
                    },
                    n = this,
                    i = 0;
                    i < 10;
                    i++
                )
                    a(i);
                this.scheduleOnce(function () {
                    o();
                }, 0.3);
            }),
            (t.prototype.getRoleSkele = function (e, t) {
                i.default.loadBundleRes(
                    "Role",
                    this.role_ske_list[e - 1],
                    function (e) {
                        t(e);
                    },
                    sp.SkeletonData
                );
            }),
            (t.prototype.playerTaskOverInfo = function (e, t) {
                var o = n.GlobalParams.PlayerTaskInfo.value;
                -1 != o.schedule[e] &&
                    ((o.schedule[e] += t),
                        (n.GlobalParams.PlayerTaskInfo.value = o),
                        l.EventManager.raiseEvent(a.default.SEND_UPDATE_TASK_INFO));
            }),
            oo([m(cc.Node)], t.prototype, "top_view_node", void 0),
            oo([m(cc.Node)], t.prototype, "coinNode", void 0),
            oo([m(cc.Node)], t.prototype, "coinFab", void 0),
            oo([m(cc.Node)], t.prototype, "zs_Node", void 0),
            oo([m(cc.Node)], t.prototype, "zsFab", void 0),
            oo([m(cc.Node)], t.prototype, "sp_node", void 0),
            oo([m(cc.Node)], t.prototype, "spFab", void 0),
            oo([m(cc.Node)], t.prototype, "fhb_node", void 0),
            oo([m(cc.Node)], t.prototype, "fhbFab", void 0),
            oo([m(cc.Node)], t.prototype, "tyk_node", void 0),
            oo([m(cc.Node)], t.prototype, "tykFab", void 0),
            oo([p], t)
        );
    })(cc.Component);
o.default = f;
